/*
 * Compression.h
 *
 *  Copyright   : Copyright © 2011 Binda&Aeolus; All Rights Reserved
 *  Created on: 2011-3-20
 *  Author      :洪春晓
 */

#ifndef COMPRESSION_H_
#define COMPRESSION_H_
#include <string>
#define LMAX 256
#define HEADER 11
using namespace std;
class Compression {
public:
	int pixel_num;//像素点个数
	int *pixel_sequence;//像素序列
	int *store_size;//前i个像素序列所用到的存储位数
	int *length_sequ;//第i个像素序列有多少个像素点
	int *pixel_len;//第i个像素用pixel_len[i]位来保存
public:
	Compression(int pixel_num,int *pixel_sequence,int *store_size,int *length_sequ,int *pixel_len);

	Compression();
	void compress_file(const string filename);
    void uncompress_file(const string source_filename,int skit_num);//,const string uncompress_filename);
	virtual ~Compression();
private:
	void output(const string filename);//int int *store_size,int *length_sequ,int *pixel_len,int pixel_num);
	void write_to_file(const string filename,int seg_num);
	int read_from_file(const string filename,int skit_num);//返回段数
	void traceback(int current_pixedl_num,int &segmentIndex);//,int *store_size,int *length_sequ);
	int length(int n);
};

#endif /* COMPRESSION_H_ */
